{% extends 'base.html.twig' %}

{% block title 'Remote Repositories' %}

{% block alt_title 'Configure remote code repositories' %}

{% block content %}
<div class="row">
    <div class="col-xs-12">
        <div class="box box-warning">
            <div class="box-header">
                <h3 class="box-title">Showing all configured remote repositories</h3>
                <div class="box-controls">
                    <a class="btn btn-default" href="{{ path('manage_remote_new') }}"><i class="fa fa-plus"></i> New Remote</a>
                </div>
            </div>
            <div class="box-body table-responsive">
                {% if remotes|length %}
                <table class="table table-bordered" id="remote-list">
                    <thead>
                        <tr>
                            <th>Name</th>
                            <th>Enabled</th>
                            <th>Actions</th>
                        </tr>
                    </thead>
                    <tbody>
                        {% for remote in remotes %}
                        <tr>
                            <td>{{ remote.name }}</td>
                            <td>{{ remote.enabled ? 'Enabled' : 'Disabled' }}</td>
                            <td>
                                <div class="btn-group">
                                    <a class="btn btn-default" href="{{ path('manage_remote_edit', { id: remote.id }) }}"><i class="fa fa-edit"></i> Edit</a>
                                    {% if remote.enabled %}
                                    <a class="btn btn-default" href="{{ path('manage_remote_sync', { id: remote.id }) }}"><i class="fa fa-refresh"></i> Sync</a>
                                    {% endif %}
                                </div>
                            </td>
                        </tr>
                        {% endfor %}
                    </tbody>
                </table>
                {% else %}
                <h4>No remotes configured. <a href="{{ path('manage_remote_new') }}">Add a new remote</a>.</h4>
                {% endif %}
            </div>
        </div>
    </div>

</div>
{% endblock %}

{% block javascripts %}
<script type="text/javascript">
    $(document).ready(function() {
        $('#remote-list').DataTable({
            "pageLength": 100,
            "stateSave": true,
            "drawCallback": window.fixContainerHeights,
            "order": [[1, 'desc'], [0, 'asc']]
        });
    });
</script>
{% endblock %}
